# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.shortcuts import render
from service import videoControl

# Create your views here.


def video(request, *args, **kwargs):
	context = {}

	current_url = request.path  # 该视图所映射的url，即当前url
	# print current_url

	# 获取url中的参数
	# print kwargs
	direction_id = kwargs.get('direction_id')
	classification_id = kwargs.get('classification_id')
	level_id = kwargs.get('level_id')

	# 查询视频数据的过滤条件定义为字典q
	q = {}
	q['status'] = 1

	derction_queryset = videoControl.get_derction(request)
	context['derction_queryset'] = derction_queryset

	classification_queryset, current_url = videoControl.get_classification(request, current_url, direction_id, classification_id)
	context['classification_queryset'] = classification_queryset

	level_list = videoControl.get_level(request)
	context['level_list'] = level_list

	video_queryset = videoControl.get_video(request, **q)
	context['video_queryset'] = video_queryset

	context['current_url'] = current_url

	return render(request, 'video.html', context=context)
